package ltd.newbee.mall.entity;

import lombok.Data;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 分页查询参数
 */
@Data
public class PageQuery extends LinkedHashMap<String, Object> {
    //当前页码
    private int pageIndex;
    //每页条数
    private int pageSize;

    public PageQuery(Map<String, Object> params) {
        this.putAll(params);
        this.pageIndex = Integer.parseInt(params.get("pageIndex").toString());
        this.pageSize = Integer.parseInt(params.get("pageSize").toString());
        this.put("start", (pageIndex - 1) * pageSize);
        this.put("pageIndex", pageIndex);
        this.put("pageSize", pageSize);
    }
}
